<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/api.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<title>CMssqlSqlsrvPdoAdapter</title>
</head>

<body>
<div id="apiPage">

<div id="apiHeader">
<a href="http://www.yiiframework.com">Yii Framework</a> v1.1.17 Class Reference
</div><!-- end of header -->

<div id="content">
<h1>CMssqlSqlsrvPdoAdapter</h1>
<div id="nav">
<a href="index.html">All Packages</a>
| <a href="#methods">Methods</a>
</div>

<table class="summaryTable docClass">
<colgroup>
	<col class="col-name" />
	<col class="col-value" />
</colgroup>
<tr>
  <th>Package</th>
  <td><a href="index.html#system.db.schema.mssql">system.db.schema.mssql</a></td>
</tr>
<tr>
  <th>Inheritance</th>
  <td>class CMssqlSqlsrvPdoAdapter &raquo;
PDO</td>
</tr>
<tr>
  <th>Since</th>
  <td>1.1.13</td>
</tr>
<tr>
  <th>Source Code</th>
  <td><a class="sourceLink" href="https://github.com/yiisoft/yii/blob/1.1.17/framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php">framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php</a></td>
</tr>
</table>

<div id="classDescription">
This is an extension of default PDO class for MSSQL SQLSRV driver only.
It provides workaround of the improperly implemented functionalities of PDO SQLSRV driver.</div>
<a name="properties"></a>

<a name="methods"></a>

<div class="summary docMethod">
<h2>Public Methods</h2>

<p><a href="#" class="toggle">Hide inherited methods</a></p>

<table class="summaryTable">
<colgroup>
	<col class="col-method" />
	<col class="col-description" />
	<col class="col-defined" />
</colgroup>
<tr>
  <th>Method</th><th>Description</th><th>Defined By</th>
</tr>
<tr class="inherited" id="__construct">
  <td>__construct()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="__sleep">
  <td>__sleep()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="__wakeup">
  <td>__wakeup()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="beginTransaction">
  <td>beginTransaction()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="commit">
  <td>commit()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="errorCode">
  <td>errorCode()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="errorInfo">
  <td>errorInfo()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="exec">
  <td>exec()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="getAttribute">
  <td>getAttribute()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="getAvailableDrivers">
  <td>getAvailableDrivers()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="inTransaction">
  <td>inTransaction()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr id="lastInsertId">
  <td><a href="CMssqlSqlsrvPdoAdapter.html#lastInsertId-detail">lastInsertId()</a></td>
  <td>Returns last inserted ID value.</td>
  <td>CMssqlSqlsrvPdoAdapter</td>
</tr>
<tr class="inherited" id="prepare">
  <td>prepare()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="query">
  <td>query()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="quote">
  <td>quote()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="rollBack">
  <td>rollBack()</td>
  <td></td>
  <td>PDO</td>
</tr>
<tr class="inherited" id="setAttribute">
  <td>setAttribute()</td>
  <td></td>
  <td>PDO</td>
</tr>
</table>
</div>
<a name="events"></a>

<h2>Method Details</h2>

<div class="detailHeader" id="lastInsertId-detail">
lastInsertId()
<span class="detailHeaderTag">
method
</span>
</div>

<table class="summaryTable">
<tr><td colspan="3">
<div class="signature2">
public integer <b>lastInsertId</b>(string|null $sequence=NULL)</div>
</td></tr>
<tr>
  <td class="paramNameCol">$sequence</td>
  <td class="paramTypeCol">string|null</td>
  <td class="paramDescCol">the sequence name. Defaults to null.</td>
</tr>
<tr>
  <td class="paramNameCol">{return}</td>
  <td class="paramTypeCol">integer</td>
  <td class="paramDescCol">last inserted ID value.</td>
</tr>
</table>

<div class="sourceCode">
<b>Source Code:</b> <a class="sourceLink" href="https://github.com/yiisoft/yii/blob/1.1.17/framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php#L30">framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php#30</a> (<b><a href="#" class="show">show</a></b>)
<div class="code"><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #007700">public&nbsp;function&nbsp;</span><span style="color: #0000BB">lastInsertId</span><span style="color: #007700">(</span><span style="color: #0000BB">$sequence</span><span style="color: #007700">=</span><span style="color: #0000BB">null</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: #0000BB">$sequence</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">lastInsertId</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">lastInsertId</span><span style="color: #007700">(</span><span style="color: #0000BB">$sequence</span><span style="color: #007700">);<br />}</span>
</span>
</code></div>
</div>
<p>Returns last inserted ID value.
SQLSRV driver supports PDO::lastInsertId() with one peculiarity: when $sequence's value is null or empty
string it returns empty string. But when parameter is not specified at all it's working as expected
and returns actual last inserted ID (like other PDO drivers).</p>


</div><!-- end of content -->

<div id="apiFooter">
&copy; 2008-2013 by <a href="http://www.yiisoft.com">Yii Software LLC</a><br/>
All Rights Reserved.<br/>
</div><!-- end of footer -->

<script type="text/javascript">
/*<![CDATA[*/
$("a.toggle").toggle(function(){
	$(this).text($(this).text().replace(/Hide/,'Show'));
	$(this).parents(".summary").find(".inherited").hide();
},function(){
	$(this).text($(this).text().replace(/Show/,'Hide'));
	$(this).parents(".summary").find(".inherited").show();
});
$(".sourceCode a.show").toggle(function(){
	$(this).text($(this).text().replace(/show/,'hide'));
	$(this).parents(".sourceCode").find("div.code").show();
},function(){
	$(this).text($(this).text().replace(/hide/,'show'));
	$(this).parents(".sourceCode").find("div.code").hide();
});
$("a.sourceLink").click(function(){
	$(this).attr('target','_blank');
});
/*]]>*/
</script>

</div><!-- end of page -->
</body>
</html>